<%--
  Created by IntelliJ IDEA.
  User: lilocal
  Date: 2017/7/25
  Time: 15:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加</title>
    <script type="text/javascript" src="../plugs/js/jquery-1.7.2.js"></script>
</head>
<body>
<form id="addForm" action="../user/addUser" method="post">
    ID：<input type="text" name="id"><br>
    用户名：<input type="text" name="username"><br>
    密码：<input type="password" name="password"><br>
    性别:<input type="text" name="sex"><br>
    <button type="button" onclick="add()">添加</button>
</form>

<script  type="text/javascript">
    function add()
    {
        $.ajax({
            type: 'post',
            url: $('#addForm').attr('action'),
            data: $('#addForm').serialize(),
            dataType: 'json',
            success: function (data) {
                if (data.result == "successful") {
                    alert("添加成功");
                    location.href = '../user/addSuccess';
                } else {
                    alert("添加失败！");
                }
            },
            error : function(err,status){
                alert(status);
                alert(err);
            }

        });
    }
</script>


</body>
</html>
